import Vue from 'vue'
import Router from 'vue-router'

/* Layout */
import Layout from '../views/layout/layout'

const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)

//所有权限通用路由表 
//如首页和登录页和一些不用权限的公用页面
export const constantRouterMap = [
  { path: '/login', component: _import('login/login'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'dashboard', noCache: true }
    }]
  },
  {
    path: '/documentation',
    component: Layout,
    redirect: '/documentation/test',
    children: [{
      path: 'test',
      component: _import('test/test'),
      name: 'documentation',
      meta: { title: '权限测试页', icon: 'documentation', noCache: true }
    }]
  }
]

export default new Router({
  mode: 'history',
  routes: constantRouterMap
})


//异步挂载的路由
//动态需要根据权限加载的路由表 
export const asyncRouterMap = [
  {
    path: '/bookList',
    component: Layout,
    children:[{
      path: 'index',
      component: _import('bookList/bookList'),
      name: 'bookList',
      meta: {title: '书籍', icon: 'icon', noCache: true }
    }]
  },
  { path: '*', redirect: '/404', hidden: true }
];
